package com.gitee.wsl.mathematics.geometry.shape

import com.gitee.wsl.unit.angle.AngleUnit
import com.gitee.wsl.unit.angle.toRadians

class Slice( circle: Circle,
             startAngle: AngleUnit = 0.0f.toRadians(),
             sweepAngle: AngleUnit = 0.0f.toRadians(),
             val innerRadius: Float = 0.5f,
             val outerRadius: Float = 1.0f,
             padAngle: AngleUnit = 0f.toRadians(),
         ): Arc(circle, startAngle, sweepAngle,false)

/**
 * private const val TAU = (2 * PI).toFloat()
 * fun invoke(data: List<T>): List<Slice<T>> {
 *         if (data.isEmpty()) return emptyList()
 *
 *         val da = min(TAU, max(-TAU, endAngle - startAngle))
 *         val p = min(abs(da) / data.size, padAngle)
 *         val pa = p * (if (da < 0) -1 else 1)
 *
 *         val values = data.map(value)
 *         check(values.all { it >= 0 }) {
 *             val index = values.indexOfFirst { it < 0 }
 *             "Values must be greater than or equal to zero, but got `${values[index]}` for item `${data[index]}`."
 *         }
 *         check(values.any { it > 0f }) { "At least one value must be greater than zero, but were all zero for items `$data`." }
 *         val sum = values.sum()
 *
 *         var angle = startAngle
 *         val k = (da - data.size * pa) / sum
 *         return values.mapIndexed { index, value ->
 *             val endAngle = angle + (value * k) + pa
 *             Slice(
 *                 data = data[index],
 *                 value = value,
 *                 index = index,
 *                 startAngle = angle,
 *                 endAngle = endAngle,
 *                 padAngle = p,
 *             ).also {
 *                 angle = endAngle
 *             }
 *         }
 *  }
 *
 */